from django.shortcuts import render

# Create your views here.
from django.views import View

from apps.contents.models import ContentCategory
from apps.contents.utils import get_categories


class IndexView(View):
    def get(self, request):
        cotegories = get_categories()
        contents = {}
        content_categories = ContentCategory.objects.all()
        for cat in content_categories:
            contents[cat.key] = cat.content_set.filter(status=True).order_by('sequence')
        context = {
            'categories': cotegories,
            'contents': contents,
        }
        return render(request, 'index.html', context=context)


# from fdfs_client.client import Fdfs_client
# client = Fdfs_client('utils/fastdfs/client.conf')
# client.upload_by_filename('/home/python/Desktop/tieba/275F8FBD06F175E1804D25F9FC1D8989.jpg')
'''
{'Remote file_id': 'group1/M00/00/00/wKgpiV0y2TCAXH_NAAIIZjQE3r8968.jpg',
'Status': 'Upload successed.',
'Storage IP': '192.168.41.137',
'Group name': 'group1',
'Uploaded size': '130.00KB',
'Local file name': '/home/python/Desktop/tieba/275F8FBD06F175E1804D25F9FC1D8989.jpg'}
'''
